package com.sk.cardeal.act.home.activity;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.alibaba.fastjson.JSON;
import com.baidu.ocr.ui.camera.CameraActivity;
import com.codbking.widget.DatePickDialog;
import com.codbking.widget.OnSureLisener;
import com.codbking.widget.bean.DateType;
import com.dyhdyh.widget.loading.dialog.LoadingDialog;
import com.sk.cardeal.R;
import com.sk.cardeal.app.MyApplication;
import com.sk.cardeal.base.BaseActivity;
import com.sk.cardeal.callback.ChooseSexDialogFragment;
import com.sk.cardeal.callback.HandleDataCallBack;
import com.sk.cardeal.dialog.KeyBoardDialogFtagment;
import com.sk.cardeal.entity.Brand;
import com.sk.cardeal.entity.BrandListBean;
import com.sk.cardeal.entity.CompanyList;
import com.sk.cardeal.entity.DataDictionary;
import com.sk.cardeal.entity.DataDictionaryList;
import com.sk.cardeal.entity.JiaShiEntity;
import com.sk.cardeal.entity.Model;
import com.sk.cardeal.entity.NewCustomEntity;
import com.sk.cardeal.entity.XingShiEntity;
import com.sk.cardeal.utils.AppApi;
import com.sk.cardeal.utils.FileUtil;
import com.sk.cardeal.utils.MyApplicationLike;
import com.sk.cardeal.utils.MyUtils;
import com.sk.cardeal.utils.RecognizeService;
import com.sk.cardeal.utils.SnackUtils;
import com.sk.cardeal.utils.UpLoadUtils;
import com.sk.cardeal.view.ExpandLayout;
import com.sk.cardeal.view.LineMenuView;
import com.sk.cardeal.view.TitleView;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;
import cn.addapp.pickers.listeners.OnItemPickListener;
import cn.addapp.pickers.picker.SinglePicker;

import static com.sk.cardeal.common.Constants.CHOOSE_CAR_TYPE;
import static com.sk.cardeal.common.Constants.UPLOAD_JIASHI;
import static com.sk.cardeal.common.Constants.UPLOAD_XINGSHI;

/**
 * Created by sk on 2017/12/25.
 */

public class NewCustomInfoActivity extends BaseActivity implements HandleDataCallBack {

    @BindView(R.id.title_view)
    TitleView titleView;
    @BindView(R.id.scan)
    ImageView scan;
    @BindView(R.id.tv_up_load)
    TextView tvUpLoad;
    @BindView(R.id.ed_in_put)
    EditText edInPut;
    @BindView(R.id.ed_car_num)
    EditText edCarNum;
    @BindView(R.id.next)
    ImageView next;
    @BindView(R.id.car_type)
    TextView carType;
    @BindView(R.id.car_model_type)
    LineMenuView carModelType;
    @BindView(R.id.vehicle_code)
    EditText vehicleCode;
    @BindView(R.id.engine_number)
    EditText engineNumber;
    @BindView(R.id.use_type)
    EditText useType;
    @BindView(R.id.validity_date)
    LineMenuView validityDate;
    @BindView(R.id.contact_phone)
    EditText contactPhone;
    @BindView(R.id.edit_sex)
    TextView editSex;
    @BindView(R.id.birth_data)
    LineMenuView birthData;
    @BindView(R.id.edit_location)
    EditText editLocation;
    @BindView(R.id.id_code)
    EditText idCode;
    @BindView(R.id.ed_work_address)
    EditText edWorkAddress;
    @BindView(R.id.custom_expand)
    ExpandLayout customExpand;
    @BindView(R.id.scan_jiashi)
    ImageView scanJiashi;
    @BindView(R.id.upload_jiashi)
    TextView uploadJiashi;
    @BindView(R.id.allow_car)
    TextView allowCar;
    @BindView(R.id.get_date)
    TextView getDate;
    @BindView(R.id.start_date)
    TextView startDate;
    @BindView(R.id.end_date)
    TextView endDate;
    @BindView(R.id.car_color)
    EditText carColor;
    @BindView(R.id.reach_date)
    LineMenuView reachDate;
    @BindView(R.id.inspection_reach_date)
    LineMenuView inspectionReachDate;
    @BindView(R.id.ed_com1)
    TextView edCom1;
    @BindView(R.id.insurance_reach_date)
    LineMenuView insuranceReachDate;
    @BindView(R.id.ed_com2)
    TextView edCom2;
    @BindView(R.id.car_expand)
    ExpandLayout carExpand;
    @BindView(R.id.save)
    TextView save;
    @BindView(R.id.custom_detail_ll)
    RelativeLayout customDetailLl;
    @BindView(R.id.car_details_ll)
    RelativeLayout carDetailsLl;
    @BindView(R.id.xs_image)
    ImageView xsImage;
    @BindView(R.id.car_loc)
    TextView carLoc;
    @BindView(R.id.js_image)
    ImageView jsImage;

    private NewCustomEntity newCustomEntity;
    private NewCustomEntity.BaseCustomerCarBean baseCustomerCarBean;
    private NewCustomEntity.BaseCustomerCertificatesBean baseCustomerCertificatesBean;
    private LoadingDialog loadingDialog;
    private String typeId;
    private int what;

    private String xsUrl = "", jsUrl = "";
    private List<CompanyList.ResultListBean> comDataList = new ArrayList<>();
    private List<DataDictionary> carTypeList = new ArrayList<>();

    @Override
    protected int getContentView() {
        return R.layout.activity_new_custom_info;
    }

    @SuppressLint("ClickableViewAccessibility")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        loadingDialog = MyUtils.getLoadingDialog(mContext, false);
        newCustomEntity = new NewCustomEntity();
        baseCustomerCarBean = new NewCustomEntity.BaseCustomerCarBean();
        baseCustomerCertificatesBean = new NewCustomEntity.BaseCustomerCertificatesBean();
        titleView.setMyCallBack(this);
        customExpand.collapse();
        carExpand.collapse();
        AppApi.getAllCarTypes(this, 3, this);
        AppApi.getAllCompany(this, 2, this);
    }

    @Override
    public void clickTitle(int i) {
        super.clickTitle(i);
        switch (i) {
            case 1:
                finish();
                break;
            case 2:
                break;
            case 3:
                break;
        }
    }

    @OnClick({R.id.car_loc,R.id.ed_com1, R.id.ed_com2, R.id.scan_jiashi, R.id.upload_jiashi, R.id.custom_detail_ll, R.id.car_details_ll, R.id.scan, R.id.tv_up_load, R.id.birth_data, R.id.insurance_reach_date, R.id.inspection_reach_date, R.id.car_type, R.id.car_model_type, R.id.save, R.id.validity_date, R.id.reach_date, R.id.edit_sex})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.car_loc:
                KeyBoardDialogFtagment keyBoardDialogFtagment = new KeyBoardDialogFtagment();
                keyBoardDialogFtagment.setMyCallBack(NewCustomInfoActivity.this);
                keyBoardDialogFtagment.show(getFragmentManager(),"key");
                break;
            case R.id.custom_detail_ll:
                customExpand.toggleExpand();
                break;
            case R.id.car_details_ll:
                carExpand.toggleExpand();
                break;
            case R.id.validity_date:
                DatePickDialog validitydDialog = new DatePickDialog(this);
                //设置上下年分限制
                validitydDialog.setYearLimt(12);
                //设置标题
                validitydDialog.setTitle("选择进场日期");
                //设置类型
                validitydDialog.setType(DateType.TYPE_ALL);
                //设置消息体的显示格式，日期格式
                validitydDialog.setMessageFormat("yyyy-MM-dd HH:mm");
                //设置选择回调
                validitydDialog.setOnChangeLisener(null);
                //设置点击确定按钮回调
                validitydDialog.setOnSureLisener(new OnSureLisener() {
                    @Override
                    public void onSure(Date date) {
                        validityDate.setHint(MyUtils.stampToDate(date.getTime()));
                        newCustomEntity.setDLEndTime(MyUtils.stampToDate(date.getTime()));
                        validityDate.setHintColor(Color.parseColor("#232323"));
                    }
                });
                validitydDialog.show();
                break;
            case R.id.scan:
                if (MyApplicationLike.isHasGotToken()) {
                    Intent scanIntent = new Intent(mContext, CameraActivity.class);
                    scanIntent.putExtra(CameraActivity.KEY_OUTPUT_FILE_PATH,
                            FileUtil.getSaveFile(getApplication()).getAbsolutePath());
                    scanIntent.putExtra(CameraActivity.KEY_CONTENT_TYPE,
                            CameraActivity.CONTENT_TYPE_BANK_CARD);
                    startActivityForResult(scanIntent, UPLOAD_XINGSHI);
                } else {
                    SnackUtils.showError(mRootView, "ocr扫描尚未准备就绪！");
                }

                break;
            case R.id.tv_up_load:
                if (MyApplicationLike.isHasGotToken()) {
                    Intent intent = new Intent(mContext, CameraActivity.class);
                    intent.putExtra(CameraActivity.KEY_OUTPUT_FILE_PATH,
                            FileUtil.getSaveFile(getApplication()).getAbsolutePath());
                    intent.putExtra(CameraActivity.KEY_CONTENT_TYPE,
                            CameraActivity.CONTENT_TYPE_BANK_CARD);
                    startActivityForResult(intent, UPLOAD_XINGSHI);
                } else {
                    SnackUtils.showError(mRootView, "ocr扫描尚未准备就绪！");
                }
                break;
            case R.id.birth_data:
                DatePickDialog dialog = new DatePickDialog(this);
                //设置上下年分限制
                dialog.setYearLimt(5);
                //设置标题
                dialog.setTitle("选择进场日期");
                //设置类型
                dialog.setType(DateType.TYPE_ALL);
                //设置消息体的显示格式，日期格式
                dialog.setMessageFormat("yyyy-MM-dd HH:mm");
                //设置选择回调
                dialog.setOnChangeLisener(null);
                //设置点击确定按钮回调
                dialog.setOnSureLisener(new OnSureLisener() {
                    @Override
                    public void onSure(Date date) {
                        birthData.setHint(MyUtils.stampToDate(date.getTime()));
                        newCustomEntity.setBirthday(MyUtils.stampToDate(date.getTime()));
                        birthData.setHintColor(Color.parseColor("#232323"));
                    }
                });
                dialog.show();
                break;
            case R.id.insurance_reach_date:

                DatePickDialog dialog1 = new DatePickDialog(this);
                //设置上下年分限制
                dialog1.setYearLimt(12);
                //设置标题
                dialog1.setTitle("选择进场日期");
                //设置类型
                dialog1.setType(DateType.TYPE_ALL);
                //设置消息体的显示格式，日期格式
                dialog1.setMessageFormat("yyyy-MM-dd HH:mm");
                //设置选择回调
                dialog1.setOnChangeLisener(null);
                //设置点击确定按钮回调
                dialog1.setOnSureLisener(new OnSureLisener() {
                    @Override
                    public void onSure(Date date) {
                        insuranceReachDate.setHint(MyUtils.stampToDate(date.getTime()));
                        baseCustomerCarBean.setSaliOutDate(MyUtils.stampToDate(date.getTime()));
                        insuranceReachDate.setHintColor(Color.parseColor("#232323"));
                    }
                });
                dialog1.show();

                break;
            case R.id.inspection_reach_date:

                DatePickDialog dialog2 = new DatePickDialog(this);
                //设置上下年分限制
                dialog2.setYearLimt(12);
                //设置标题
                dialog2.setTitle("选择进场日期");
                //设置类型
                dialog2.setType(DateType.TYPE_ALL);
                //设置消息体的显示格式，日期格式
                dialog2.setMessageFormat("yyyy-MM-dd HH:mm");
                //设置选择回调
                dialog2.setOnChangeLisener(null);
                //设置点击确定按钮回调
                dialog2.setOnSureLisener(new OnSureLisener() {
                    @Override
                    public void onSure(Date date) {
                        inspectionReachDate.setHint(MyUtils.stampToDate(date.getTime()));
                        baseCustomerCarBean.setInsuranceOutDate(MyUtils.stampToDate(date.getTime()));
                        inspectionReachDate.setHintColor(Color.parseColor("#232323"));
                    }
                });
                dialog2.show();
                break;
            case R.id.car_model_type:
                loadingDialog.show();
                AppApi.getCarBrand(NewCustomInfoActivity.this, 1, NewCustomInfoActivity.this);
                break;
            case R.id.save:

                if (xsUrl == null || xsUrl.length() == 0) {
                    SnackUtils.showError(mRootView, "请上传行驶证！");
                    return;
                }

                if (TextUtils.isEmpty(edInPut.getText().toString())) {
                    SnackUtils.showError(mRootView, "请填写所属人姓名！");
                    return;
                }
                if (TextUtils.isEmpty(contactPhone.getText().toString())) {
                    SnackUtils.showError(mRootView, "请填写联系电话！");
                    return;
                }

                setData();
                loadingDialog.show();
                AppApi.insertCustom(newCustomEntity, NewCustomInfoActivity.this, 10, NewCustomInfoActivity.this);
                break;
            case R.id.upload_jiashi:

                if (MyApplicationLike.isHasGotToken()) {
                    Intent scanIntent = new Intent(mContext, CameraActivity.class);
                    scanIntent.putExtra(CameraActivity.KEY_OUTPUT_FILE_PATH,
                            FileUtil.getSaveFile(getApplication()).getAbsolutePath());
                    scanIntent.putExtra(CameraActivity.KEY_CONTENT_TYPE,
                            CameraActivity.CONTENT_TYPE_BANK_CARD);
                    startActivityForResult(scanIntent, UPLOAD_JIASHI);
                } else {
                    SnackUtils.showError(mRootView, "ocr扫描尚未准备就绪！");
                }

                break;
            case R.id.scan_jiashi:

                if (MyApplicationLike.isHasGotToken()) {
                    Intent scanIntent = new Intent(mContext, CameraActivity.class);
                    scanIntent.putExtra(CameraActivity.KEY_OUTPUT_FILE_PATH,
                            FileUtil.getSaveFile(getApplication()).getAbsolutePath());
                    scanIntent.putExtra(CameraActivity.KEY_CONTENT_TYPE,
                            CameraActivity.CONTENT_TYPE_BANK_CARD);
                    startActivityForResult(scanIntent, UPLOAD_JIASHI);
                } else {
                    SnackUtils.showError(mRootView, "ocr扫描尚未准备就绪！");
                }

                break;
            case R.id.reach_date:

                final DatePickDialog reachDialog = new DatePickDialog(this);
                //设置上下年分限制
                reachDialog.setYearLimt(5);
                //设置标题
                reachDialog.setTitle("选择进场日期");
                //设置类型
                reachDialog.setType(DateType.TYPE_ALL);
                //设置消息体的显示格式，日期格式
                reachDialog.setMessageFormat("yyyy-MM-dd HH:mm");
                //设置选择回调
                reachDialog.setOnChangeLisener(null);
                //设置点击确定按钮回调
                reachDialog.setOnSureLisener(new OnSureLisener() {
                    @Override
                    public void onSure(Date date) {
                        reachDate.setHint(MyUtils.stampToDate(date.getTime()));
                        baseCustomerCarBean.setAnnualInspectionDate(MyUtils.stampToDate(date.getTime()));
                        reachDate.setHintColor(Color.parseColor("#232323"));
                    }
                });
                reachDialog.show();

                break;

            case R.id.edit_sex:
                ChooseSexDialogFragment chooseSexDialogFragment = new ChooseSexDialogFragment();
                chooseSexDialogFragment.setMyCallBack(NewCustomInfoActivity.this);
                chooseSexDialogFragment.show(getSupportFragmentManager(), "sex");
                break;
            case R.id.ed_com1:

                List<String> stringList = new ArrayList<>();
                for (int i = 0; i < comDataList.size(); i++) {
                    stringList.add(comDataList.get(i).getText());
                }
                SinglePicker<String> picker = new SinglePicker<>(this, stringList);
                picker.setCanLoop(false);//不禁用循环
                picker.setLineVisible(true);
                picker.setShadowVisible(true);
                picker.setTextSize(30);
                picker.setSelectedIndex(0);
                picker.setWheelModeEnable(true);
                picker.setWeightEnable(true);
                picker.setWeightWidth(1);
                picker.setSelectedTextColor(0xFF279BAA);//前四位值是透明度
                picker.setUnSelectedTextColor(0xFF999999);
                picker.setOnItemPickListener(new OnItemPickListener<String>() {
                    @Override
                    public void onItemPicked(int i, String s) {
                        edCom1.setText(s);
                    }
                });
                picker.show();

                break;
            case R.id.ed_com2:
                List<String> stringList2 = new ArrayList<>();
                for (int i = 0; i < comDataList.size(); i++) {
                    stringList2.add(comDataList.get(i).getText());
                }
                SinglePicker<String> picker2 = new SinglePicker<>(this, stringList2);
                picker2.setCanLoop(false);//不禁用循环
                picker2.setLineVisible(true);
                picker2.setShadowVisible(true);
                picker2.setTextSize(30);
                picker2.setSelectedIndex(0);
                picker2.setWheelModeEnable(true);
                picker2.setWeightEnable(true);
                picker2.setWeightWidth(1);
                picker2.setSelectedTextColor(0xFF279BAA);//前四位值是透明度
                picker2.setUnSelectedTextColor(0xFF999999);
                picker2.setOnItemPickListener(new OnItemPickListener<String>() {
                    @Override
                    public void onItemPicked(int i, String s) {
                        edCom2.setText(s);
                    }
                });
                picker2.show();
                break;
        }
    }

    private void setData() {

        newCustomEntity.setPersonName(edInPut.getText().toString());
        newCustomEntity.setTelephone(contactPhone.getText().toString());

        newCustomEntity.setCardNumber(idCode.getText().toString());
        newCustomEntity.setAddress(editLocation.getText().toString());
        newCustomEntity.setUserId(MyUtils.getUser(mContext).getId());

        newCustomEntity.setJob(edWorkAddress.getText().toString());

        baseCustomerCarBean.setPlateNumber(carLoc.getText().toString() + edCarNum.getText().toString());
        baseCustomerCarBean.setColor(carColor.getText().toString());
        baseCustomerCarBean.setVin(vehicleCode.getText().toString());
        baseCustomerCarBean.setEngineNo(engineNumber.getText().toString());
        baseCustomerCarBean.setSaliCompany(edCom2.getText().toString());
        baseCustomerCarBean.setInsuranceCompany(edCom1.getText().toString());
        baseCustomerCarBean.setUserNature(useType.getText().toString());
        newCustomEntity.setBaseCustomerCar(baseCustomerCarBean);

        baseCustomerCertificatesBean.setAddress(editLocation.getText().toString());
        baseCustomerCertificatesBean.setName(edInPut.getText().toString());
        baseCustomerCertificatesBean.setQuasi_driving(allowCar.getText().toString());
        baseCustomerCertificatesBean.setGetTime(getDate.getText().toString());
        baseCustomerCertificatesBean.setStart_time(startDate.getText().toString());
        baseCustomerCertificatesBean.setYears(endDate.getText().toString());

        newCustomEntity.setBaseCustomerCertificates(baseCustomerCertificatesBean);

    }

    @Override
    public void handlerSuccessData(String result, int tag) {
        loadingDialog.cancelDialog();
        switch (tag) {
            case 1:
                BrandListBean brandListBean = JSON.parseObject(result, BrandListBean.class);
                ArrayList<Brand> brandList = (ArrayList<Brand>) brandListBean.getResultList();
                Intent carIntent = new Intent(mContext, BrandChooseActivity.class);
                carIntent.putParcelableArrayListExtra("data", brandList);
                startActivityForResult(carIntent, CHOOSE_CAR_TYPE);
                break;
            case 2:
                CompanyList companyList = JSON.parseObject(result, CompanyList.class);
                comDataList.clear();
                comDataList.addAll(companyList.getResultList());
                break;
            case 3:
                DataDictionaryList dataDictionaryList = JSON.parseObject(result, DataDictionaryList.class);
                carTypeList = dataDictionaryList.getResultList();
                break;
            case 10:
                loadingDialog.cancelDialog();
                Toast.makeText(mContext, "客户新增成功！", Toast.LENGTH_SHORT).show();
                setResult(RESULT_OK);
                finish();
                break;
        }
    }

    @Override
    public void handlerFailData(String failString, int tag) {
        loadingDialog.cancelDialog();
    }

    @Override
    public void handleErrorData(String error, int tag) {
        loadingDialog.cancelDialog();
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, final Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == -1) {
            switch (requestCode) {
                case CHOOSE_CAR_TYPE:
                    Model model = data.getParcelableExtra("model");
                    carModelType.setHint(model.getText());
                    carModelType.setHintColor(Color.parseColor("#232323"));
                    typeId = model.getId();
                    baseCustomerCarBean.setCarTypeId(typeId);
                    break;
                case UPLOAD_XINGSHI:
                    RecognizeService.recVehicleLicense(FileUtil.getSaveFile(MyApplication.getAppContext()).getAbsolutePath(),
                            new RecognizeService.ServiceListener() {
                                @Override
                                public void onResult(String result, Bitmap bitmap) {
                                    Log.v("RecognizeService", result);
                                    if (bitmap != null) {
                                        XingShiEntity xingShiEntity = MyUtils.jsonToXingshi(result);
                                        if (xingShiEntity != null) {
                                            edInPut.setText(xingShiEntity.getOwner());
                                            xsImage.setImageBitmap(bitmap);

                                            if (xingShiEntity.getCarNumber() != null && xingShiEntity.getCarNumber().length() == 7) {
                                                carLoc.setText(xingShiEntity.getCarNumber().substring(0, 1));
                                                edCarNum.setText(xingShiEntity.getCarNumber().substring(1, 7));
                                            }
                                            vehicleCode.setText(xingShiEntity.getCarGetCode());
                                            engineNumber.setText(xingShiEntity.getEngineNumber());
                                            useType.setText(xingShiEntity.getUseType());
                                            for (DataDictionary dataDictionary : carTypeList) {
                                                if (dataDictionary.getName().equals(xingShiEntity.getCarType())) {
                                                    baseCustomerCarBean.setCarId(dataDictionary.getId());
                                                    break;
                                                }
                                            }
                                            carType.setText(xingShiEntity.getCarType());
                                            loadingDialog.show();
                                            what = 1;
                                            UpLoadUtils.uploadPicTask(FileUtil.getSaveFile(MyApplication.getAppContext()).getAbsolutePath(), NewCustomInfoActivity.this);
                                        }
                                    } else {
                                        SnackUtils.showError(mRootView, "识别失败，请重试！");
                                    }
                                }
                            });
                    break;
                case UPLOAD_JIASHI:

                    RecognizeService.recDrivingLicense(FileUtil.getSaveFile(MyApplication.getAppContext()).getAbsolutePath(),
                            new RecognizeService.ServiceListener() {
                                @Override
                                public void onResult(String result, Bitmap bitmap) {
                                    Log.v("RecognizeService", result);
                                    if (bitmap != null) {
                                        JiaShiEntity jiaShiEntity = MyUtils.jsonToJiashi(result);

                                        if (jiaShiEntity != null) {
                                            jsImage.setImageBitmap(bitmap);
                                            allowCar.setText(jiaShiEntity.getDriveCarType());
                                            getDate.setText(MyUtils.getDate(jiaShiEntity.getOnceGetDate()));
                                            startDate.setText(MyUtils.getDate(jiaShiEntity.getStartTime()));
                                            endDate.setText(jiaShiEntity.getTerm());

                                            switch (jiaShiEntity.getSex()) {
                                                case "男":
                                                    editSex.setText("男");
                                                    newCustomEntity.setSex("0");
                                                    baseCustomerCertificatesBean.setSex("0");
                                                    break;
                                                case "女":
                                                    editSex.setText("女");
                                                    newCustomEntity.setSex("1");
                                                    baseCustomerCertificatesBean.setSex("1");
                                                    break;
                                            }

                                            loadingDialog.show();
                                            what = 2;
                                            UpLoadUtils.uploadPicTask(FileUtil.getSaveFile(MyApplication.getAppContext()).getAbsolutePath(), NewCustomInfoActivity.this);
                                        }

                                    } else {
                                        SnackUtils.showError(mRootView, "识别失败，请重试！");
                                    }
                                }
                            });

                    break;

            }
        }
    }

    @Override
    public void success(String path) {
        super.success(path);
        loadingDialog.cancelDialog();
        if (what == 1) {
            xsUrl = path;
            baseCustomerCarBean.setLicensePic(path);
        } else {
            baseCustomerCertificatesBean.setDriverPic(path);
            jsUrl = path;
        }
    }

    @Override
    public void chooseSex(int sex) {
        super.chooseSex(sex);
        switch (sex) {
            case 1:
                editSex.setText("男");
                newCustomEntity.setSex("0");
                baseCustomerCertificatesBean.setSex("0");
                break;
            case 0:
                editSex.setText("女");
                newCustomEntity.setSex("1");
                baseCustomerCertificatesBean.setSex("1");
                break;
        }
    }

    @Override
    public void selectArea(String area) {
        super.selectArea(area);
        carLoc.setText(area);
    }
}
